﻿@{
    ViewBag.Title = "模块按钮列表";
    Layout = null;
}

<div class="row">
    <div class="col-md-12">
        <div class="box box-primary box-solid">
            <div class="box-header with-border">
                <h3 class="box-title">模块按钮列表</h3>
                <div class="box-tools">
                    <div class="input-group" style="width: 250px;">
                        <input type="text" class="form-control input-sm" placeholder="请输入名称进行模糊查询...">
                        <div class="input-group-btn">
                            <a class="btn btn-sm btn-default"><i class="fa fa-search"></i></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-body no-padding">
                <div class="mailbox-controls">
                    <div class="btn-group" id="partial_button_toolbar">
                        <a onclick=" addHaveFunction(); return false; " title="" data-toggle="tooltip" class="btn btn-default btn-sm" href="javascript:void(0)" data-original-title="新增">
                            <i class="fa fa-plus">新增</i>
                        </a>

                        <a onclick=" delHaveFunction(); return false; " title="" data-toggle="tooltip" class="btn btn-default btn-sm" href="javascript:void(0)" data-original-title="删除">
                            <i class="fa fa-close">删除</i>
                        </a>
                    </div>

                    <a data-toggle="tooltip" onclick="getHaveFunctionGridData()" title="刷新" class="btn btn-default btn-sm"><i class="fa fa-refresh">刷新</i></a>
                </div>
                <div class="mailbox-jqgrid">
                    <table id="haveFunctionslist"></table>
                    <div id="haveFunctionsPager"></div>
                </div>
            </div>
        </div>
    </div>
</div>
@Html.Hidden("MenubuttonId")
<script>
    $(function () {
        initHaveFunctionGrid();
    });
    var $haveFuntionsGrid;


    //初始化表格
    function initHaveFunctionGrid() {
        $haveFuntionsGrid = $("#haveFunctionslist").jgridview(
        {
            shrinkToFit: true,
            multiselect: false,
            autowidth: false,
            url: "/System/MenuButton/GetMenuButtonFunctions",
            colModel: [
                { name: "FunctionId", hidden: true },
                { label: "系统代码", name: "AppCode", width: 80, fixed: true },
                { label: "区域", name: "Area", width: 80, fixed: true },
                { label: "控制器", name: "Controller", width: 100, fixed: true },
                { label: "名称", name: "Action", width: 150, fixed: true },
                { label: "界面", name: "IsPage", width: 40, align: "center", fixed: true, formatter: "YesOrNo" },
                { label: "备注", name: "Description", width: 250, fixed: true }
            ],
            pager: "haveFunctionsPager",
            postData: {
                id: $("#MenubuttonId").val()
            },
            width:"100",
            height: "400"
        });
    }

    //获取表格数据
    function getHaveFunctionGridData() {
        UtilAjaxPost("/System/MenuButton/GetMenuButtonFunctions", { id: $("#MenubuttonId").val() }, function (data) {
            GridReloadLoadOnceData($haveFuntionsGrid, data);
        });
    }

    //操作:新增
    function addHaveFunction() {
        ArtDialogOpen("/System/MenuButton/ChosenFunctions?id=" + $("#MenubuttonId").val(), "选择关联模块按钮-" + UtilGetUrlParam("title"), true, 450, 830);
    }

    //删除匹配项
    function delHaveFunction() {
        //查看是否选中
        GridIsSelect($haveFuntionsGrid, function () {
            ArtDialogConfirm(Language.common.deletemsg, function () {
                UtilAjaxPostWait(
                    "/System/MenuButton/DeleteMenuButtonFunction",
                    {
                        functionId: GridGetSingSelectData($haveFuntionsGrid).FunctionId,
                        menuButtonId: $("#MenubuttonId").val()
                    },
                    perateStatusHaveFunction
                );
            });
        });
    }

    //请求完成
    function perateStatusHaveFunction(data) {
        DialogAjaxResult(data);
        if (data.ResultSign === 0) {
            getGridData();
        }
    }
</script>